using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TwoThreeItem : MonoBehaviour
{
    public Text Freetext, Moneytext, Numtext;
    public Transform FreeItem, MoneyItem;
    internal void init(TwoThreeData twoThreeData)
    {
        Numtext.text = twoThreeData.aimNum.ToString();
        Freetext.text = twoThreeData.free.ToString();
        Moneytext.text = twoThreeData.Money.ToString();

        if (twoThreeData.aimNum <= TwoPanel.Ins.MoneyNum)
        {
            Numtext.color = Color.yellow;
            if (twoThreeData.freeState == 0)
            {
                twoThreeData.freeState = 1;
                FreeItem.gameObject.SetActive(true);
                TwoPanel.Ins.MoneyNum += twoThreeData.free;
            }
            if (TwoPanel.Ins.IsBuy)
            {
                Debug.Log("已购买");
                if (twoThreeData.MoneyState == 0)
                {
                    twoThreeData.MoneyState = 1;
                    MoneyItem.gameObject.SetActive(true);
                    TwoPanel.Ins.MoneyNum += twoThreeData.Money;
                }
            }
        }
        else
        {
            FreeItem.gameObject.SetActive(false);
            MoneyItem.gameObject.SetActive(false);
            Numtext.color = Color.black;
        }
    }

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
}
